/*
 * PacketInfo.cpp
 *
 *  Created on: 29 sept. 2009
 *      Author: CHETIER
 */

#include "PacketInfo.h"

PacketInfo::PacketInfo(){}

PacketInfo::~PacketInfo(){}

sf::Packet& PacketInfo::operator <<(ClientInfo& Data)
{
	return *(sf::Packet*)this
		<< Data.left
		<< Data.right
		<< Data.up
		<< Data.down
		<< Data.x
		<< Data.y
		<< Data.id
		<< Data.name;
}

sf::Packet& PacketInfo::operator >>(ClientInfo& Data)
{
	return *(sf::Packet*)this
		>> Data.left
		>> Data.right
		>> Data.up
		>> Data.down
		>> Data.x
		>> Data.y
		>> Data.id
		>> Data.name;
}

sf::Packet& PacketInfo::operator <<(std::list<ClientInfo>& Data)
{
	*(sf::Packet*)this << Data.size();
	for(std::list<ClientInfo>::iterator i = Data.begin(); i != Data.end(); ++i)
		*this << *i;
	return *this;
}


sf::Packet& PacketInfo::operator >>(std::list<ClientInfo>& Data)
{
	int nbElement;
	*(sf::Packet*)this >> nbElement;
	Data.clear();
	for(int i = 0; i < nbElement; i++)
	{
		ClientInfo newClientInfo;
		*this >> newClientInfo;
		Data.push_back(newClientInfo);
	}
	return *this;
}
